package com.fgchen.study.velocity.entity;

import org.apache.velocity.util.StringUtils;

import java.util.List;

public class Table {

    private String db;

    private String name;

    private List<Column> columns;

    public String getClassName() {
        if (this.name.contains("_")) {
            String[] parts = StringUtils.split(this.name, "_");
            StringBuffer sb = new StringBuffer();
            for (String part : parts) {
                sb.append(StringUtils.firstLetterCaps(part));
            }
            return sb.toString();
        } else {
            return StringUtils.firstLetterCaps(this.name);
        }
    }

    public String getDb() {
        return db;
    }

    public Table setDb(String db) {
        this.db = db;
        return this;
    }

    public String getName() {
        return name;
    }

    public Table setName(String name) {
        this.name = name;
        return this;
    }

    public List<Column> getColumns() {
        return columns;
    }

    public Table setColumns(List<Column> columns) {
        this.columns = columns;
        return this;
    }

}
